package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-07-03
 * Time: 20:53
 */
public class ThreadDemo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            //System.out.println("Hello t");
            while (true) {
                //死循环，一直处在运行态RUNNABLE
//                try {//睡眠时间占据绝大部分线程运行时间，TIMED_WAITING
//                    Thread.sleep(9000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
            }
        });
        //启动前，获取线程状态，NEW
        System.out.println(t.getState());
        //启动
        t.start();

        Thread.sleep(2000);

        //运行状态RUNNABLE / 执行结束后的状态TERMINATED
        System.out.println(t.getState());
    }
}
